import { configureStore } from "@reduxjs/toolkit";
import userStoreReducer from "./reducers/user";
import storage from 'redux-persist/lib/storage';
import { persistStore, persistReducer } from 'redux-persist'

// 配置对象
const persistConfig = {
  key: 'user',
  storage,
}

// 创建一个新的 Redux 状态 reducer
const persistedReducer = persistReducer(persistConfig, userStoreReducer)

 const store = configureStore({
  reducer: {
    userStore: persistedReducer,
  },
});
// 创建一个新的 Redux store
const persistor = persistStore(store)

const storePersistor = { store, persistor }

export default storePersistor;